// 搜索组件
import React from 'react';
import { connect } from 'react-redux';
import { Form, Input, Select, Button, Space, DatePicker } from 'antd';
import dayjs from 'dayjs';
import { SEARCH_OPT, DELIVER_STATE_OPT, AFTER_SALE_METHOD, AFTER_SALE_STATE } from '../../../store/constants/order';
const { RangePicker } = DatePicker;

const AfterSaleSearch = () => {
  const width = 200;
  const [form] = Form.useForm();
  const onReset = params => {};
  // 日期选择器
  const rangePresets = [
    {
      label: '今天',
      value: [dayjs().add(0, 'd'), dayjs()],
    },
    {
      label: '昨天',
      value: [dayjs().add(-1, 'd'), dayjs()],
    },
    {
      label: '最近7天',
      value: [dayjs().add(-7, 'd'), dayjs()],
    },
    {
      label: '最近30天',
      value: [dayjs().add(-30, 'd'), dayjs()],
    },
  ];
  const onRangeChange = (dates, dateStrings) => {
    // if (dates) {
    //   console.log('From: ', dates[0], ', to: ', dates[1]);
    //   console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
    // } else {
    //   console.log('Clear');
    // }
  };
  return (
    <Form layout='inline' form={form}>
      <Space direction='vertical' size={20}>
        <Space>
          <Form.Item label='订单搜索'>
            <Select style={{ width }} allowClear options={SEARCH_OPT} placeholder='请选择' />
          </Form.Item>
          <Form.Item>
            <Input placeholder='请输入' style={{ width }} />
          </Form.Item>
        </Space>
        <Space>
          <Form.Item label='下单时间' name='orderTime'>
            <RangePicker presets={rangePresets} showTime format='YYYY/MM/DD HH:mm:ss' onChange={onRangeChange} />
          </Form.Item>
        </Space>
        <Space>
          <Form.Item label='售后方式'>
            <Select style={{ width }} allowClear options={AFTER_SALE_METHOD} placeholder='请选择' />
          </Form.Item>
          <Form.Item label='售后状态'>
            <Select style={{ width }} allowClear options={AFTER_SALE_STATE} placeholder='请选择' />
          </Form.Item>
          <Form.Item label='发货状态'>
            <Select style={{ width }} allowClear options={DELIVER_STATE_OPT} placeholder='请选择' />
          </Form.Item>
        </Space>
        <Space size={10} align='center'>
          <Button type='primary' htmlType='submit'>
            筛选
          </Button>
          <Button htmlType='button' onClick={onReset}>
            重置
          </Button>
          <Button htmlType='button' onClick={onReset}>
            导出
          </Button>
        </Space>
      </Space>
    </Form>
  );
};

export default connect(state => ({ afterSale: state.orderReducer }), {})(AfterSaleSearch);
